home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / asm32.zip / E32.ZIP / INS_STR.ASM < prev    next >
Assembly Source File  |  1994-01-25  |  1KB  |  45 lines

  1. ; INS_STR.ASM for E32 - Copyright (C) 1994 Douglas Herr
  2. ;  all rights reserved
  3.  
  4. include    model.inc
  5.  
  6. public    insert_string
  7. extrn    open_space:near
  8. extrn    locate:near
  9. ;
  10. ; insert_string inserts EAX characters from DS:ESI into the file
  11. ;
  12.  
  13. include    dataseg.inc
  14. extrn    cursor:dword, cur_posn:word, dirty_bits:byte
  15. @curseg    ends
  16.  
  17. include    codeseg.inc
  18. insert_string    proc    near
  19.     push    es
  20.     push    esi        ; save the string buffer
  21.     mov    esi,cursor    ; get cursor offset
  22.     push    eax        ; save length of string
  23.     push    esi
  24.     call    open_space    ; returns with ES -> file_segment
  25.     pop    edi        ; get back cursor position
  26.     pop    ecx        ; get back string length
  27.     pop    esi        ; get back buffer pointer
  28.     jc    short no_space    ; if no space available, exit
  29.     rep    movsb        ; copy the characters into the space
  30.     mov    esi,cursor    ; get the new cursor offset
  31.     mov    dx,cur_posn    ; also get the current row
  32.     push    ds
  33.     pop    es
  34.     call    locate        ; adjust the screen position
  35.     or    dirty_bits,1    ; screen needs update
  36. no_space:
  37.     clc
  38.     pop    es
  39.     ret
  40.  
  41. insert_string    endp
  42.  
  43. @curseg    ends
  44.     end
  45.